﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Primitives;
using System.Linq;
using System.Text;
using Snowdreamist.ComponentModel.Services;
using Snowdreamist.Windows.Controls;

namespace Snowdreamist.ComponentModel.MEF
{
    [MetadataAttribute]
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
    public class DataTemplateExportAttribute : ExportAttribute, IDataTemplateMetadata
    {
        public DataTemplateExportAttribute(Type targetType) : this(targetType, null) { }

        public DataTemplateExportAttribute(Type targetType, string viewState) : this(targetType.FullName, viewState) { }

        public DataTemplateExportAttribute(string targetTypeName) : this(targetTypeName, null) { }

        public DataTemplateExportAttribute(string targetTypeName, string viewState)
            : base(typeof(IDataTemplateFactory))
        {
            this.TargetTypeName = targetTypeName;
            this.ViewState = viewState;
        }

        /// <summary>
        /// Typename
        /// </summary>
        public string TargetTypeName { get; private set; }

        /// <summary>
        /// ViewState
        /// </summary>
        public string ViewState { get; private set; }

        /// <summary>
        /// Scope
        /// </summary>
        public string Scope { get; set; }
    }
}